Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsdevtools/ono

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsdevtools/ono

Throw better errors.

  • 7.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @jsdevtools/ono?

The @jsdevtools/ono npm package is designed for creating and managing custom error objects in JavaScript and TypeScript applications. It provides enhanced functionality for error handling, including the ability to wrap existing errors while preserving the original error's properties and stack trace, and to create errors of specific types with additional properties.

What are @jsdevtools/ono's main functionalities?

Creating custom errors

This feature allows developers to create custom error objects with a simple message. The created error can then be thrown in the application to signal an exceptional condition.

const ono = require('@jsdevtools/ono');
const myError = ono('This is a custom error!');
throw myError;

Wrapping existing errors

This feature enables the wrapping of an existing error with additional context or properties, without losing the original error's stack trace and message. This is particularly useful for error handling in complex applications where maintaining error traceability is crucial.

const ono = require('@jsdevtools/ono');
const originalError = new Error('Original error');
const wrappedError = ono(originalError, 'Additional context');
throw wrappedError;

Creating typed errors

This feature allows the creation of errors of specific types (like TypeError, RangeError, etc.) with custom messages and properties. This is useful for throwing errors that need to be caught and handled differently based on their type.

const ono = require('@jsdevtools/ono');
const typedError = ono(TypeError, 'This is a type error with additional info');
throw typedError;

Other packages similar to @jsdevtools/ono

Keywords

FAQs

Package last updated on 15 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc